// 文件路径: com.city.java.abnormal_records.controller.AbnormalProcessingController.java
package com.city.java.abnormal_records.controller;

import com.city.java.abnormal_records.pojo.entity.AbnormalProcessing;
import com.city.java.abnormal_records.service.AbnormalProcessingService;
import com.city.java.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 异常记录处理控制器
 * RestController注解: 组合注解，相当于@Controller + @ResponseBody
 * Api注解: Knife4j文档中模块的显示名称
 * RequestMapping注解: 设置统一的请求路径前缀
 */
@Slf4j
@Api(tags = "11.异常记录处理模块")
@RestController
@RequestMapping("/api/abnormal-records/processing")
public class AbnormalProcessingController {

    @Autowired
    private AbnormalProcessingService abnormalProcessingService;

    /**
     * 添加异常记录处理
     * PostMapping注解: 处理POST请求
     * ApiOperation注解: Knife4j文档中接口的显示名称
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加异常记录处理", notes = "添加新的异常记录处理信息")
    public JsonResult addAbnormalProcessing(
            @ApiParam(value = "异常记录处理信息", required = true)
            @RequestBody AbnormalProcessing abnormalProcessing) {
        log.info("接收到添加异常记录处理请求: {}", abnormalProcessing);
        return abnormalProcessingService.addAbnormalProcessing(abnormalProcessing);
    }

    /**
     * 根据处理ID查询异常记录处理
     * GetMapping注解: 处理GET请求
     * PathVariable注解: 获取路径中的参数
     */
    @GetMapping("/select/id/{processingId}")
    @ApiOperation(value = "根据ID查询异常记录处理", notes = "根据处理ID查询异常记录处理详细信息")
    public JsonResult getAbnormalProcessingById(
            @ApiParam(value = "处理ID", required = true, example = "1")
            @PathVariable Long processingId) {
        log.info("接收到根据ID查询异常记录处理请求: ID={}", processingId);
        return abnormalProcessingService.getAbnormalProcessingById(processingId);
    }

    /**
     * 根据异常记录ID查询异常记录处理
     */
    @GetMapping("/select/abnormal/{abnormalId}")
    @ApiOperation(value = "根据异常记录ID查询处理", notes = "根据异常记录ID查询处理")
    public JsonResult getAbnormalProcessingByAbnormalId(
            @ApiParam(value = "异常记录ID", required = true, example = "1")
            @PathVariable Long abnormalId) {
        log.info("接收到根据异常记录ID查询处理请求: abnormalId={}", abnormalId);
        return abnormalProcessingService.getAbnormalProcessingByAbnormalId(abnormalId);
    }

    /**
     * 根据状态查询异常记录处理列表
     */
    @GetMapping("/select/{status}")
    @ApiOperation(value = "根据状态查询异常记录处理", notes = "根据状态查询异常记录处理列表")
    public JsonResult getAbnormalProcessingsByStatus(
            @ApiParam(value = "状态", required = true, example = "PENDING")
            @PathVariable AbnormalProcessing.ProcessingStatus status) {
        log.info("接收到根据状态查询异常记录处理请求: status={}", status);
        return abnormalProcessingService.getAbnormalProcessingsByStatus(status);
    }

    /**
     * 查询所有异常记录处理列表
     */
    @GetMapping("/quarry")
    @ApiOperation(value = "查询所有异常记录处理", notes = "查询所有异常记录处理列表")
    public JsonResult getAllAbnormalProcessings() {
        log.info("接收到查询所有异常记录处理请求");
        return abnormalProcessingService.getAllAbnormalProcessings();
    }

    /**
     * 根据处理ID删除异常记录处理
     * DeleteMapping注解: 处理DELETE请求
     */
    @DeleteMapping("/delete/id/{processingId}")
    @ApiOperation(value = "根据ID删除异常记录处理", notes = "根据处理ID删除异常记录处理")
    public JsonResult deleteAbnormalProcessingById(
            @ApiParam(value = "处理ID", required = true, example = "1")
            @PathVariable Long processingId) {
        log.info("接收到根据ID删除异常记录处理请求: ID={}", processingId);
        return abnormalProcessingService.deleteAbnormalProcessingById(processingId);
    }

    /**
     * 更新异常记录处理信息
     * PutMapping注解: 处理PUT请求
     */
    @PutMapping("/update")
    @ApiOperation(value = "更新异常记录处理信息", notes = "更新异常记录处理详细信息")
    public JsonResult updateAbnormalProcessing(
            @ApiParam(value = "异常记录处理信息", required = true)
            @RequestBody AbnormalProcessing abnormalProcessing) {
        log.info("接收到更新异常记录处理信息请求: {}", abnormalProcessing);
        return abnormalProcessingService.updateAbnormalProcessing(abnormalProcessing);
    }
}
